<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AddForm
 *
 * @author lzx
 */
require_once BaseUtil::getModulePath('base').'/forms/BaseForm.php';
require_once BaseUtil::getModulePath('consult').'/constants/ConsultConstant.php';
require_once BaseUtil::getModulePath('customer').'/services/CustomerService.php';
class AddForm extends BaseForm{
    //put your code here
    public function __construct(){
        parent::__construct();
        $this->setAction(HttpUtil::getUrl("consult","subadd"));
        // user_id
        $customerService = new CustomerService();
        $invalidUser = $customerService->getRandomInvalidUser();
        $customer = new Zend_Form_Element_Text('customerId');
        $customer->setLabel($this->translate->_('customerId'));
        $customer->setValue($invalidUser["id"]);
        $customer->addValidator("Digits");
        $customer->setRequired(true);
        //query_type
        $type = new Zend_Form_Element_Select('type');
        $type->setLabel($this->translate->_('queryType'));
        $type->setMultiOptions(ConsultConstant::getConsultTypeList());
        //product_id
        $item = new Zend_Form_Element_Text('item');
        $item->setLabel($this->translate->_('productId'));
        $item->addFilter("StringTrim");
        $item->addValidator("Digits");
        $item->setRequired(true);
        //hidden
        $hProductId = new Zend_Form_Element_Hidden("hProductId");
        $hProductId->setValue(1);//set the default product id
        $hReplayId = new Zend_Form_Element_Hidden("hReplayId");
        $user = BaseUtil::getLoginUser();
        $userid = $user['uid'];
        $hReplayId->setValue($userid);//current administrator id
        //content
        $question = new Zend_Form_Element_Textarea('question');
        $question->setLabel($this->translate->_('question'));
        $question->setAttribs(array("rows"=>6,"cols"=>30));
        $question->addFilter("StringTrim");
        $question->setRequired(true);
        //reply
        $reply = new Zend_Form_Element_Textarea('reply');
        $reply->setLabel($this->translate->_('replyContent'));
        $reply->setAttribs(array("rows"=>6,"cols"=>30));
        $reply->addFilter("StringTrim");
        $reply->setRequired(true);
        //add to phtml
        $this->addElements(array($customer, $type,$item,$question,$reply,$hProductId,$hReplayId));
        $this->setElementDecorators(array ('ViewHelper',array(array('div' =>'HtmlTag'),array('tag' =>'div',"class" => "form_element" ))));
    }

}
?>
